package service

import (
	"dc-news/dao"
	"dc-news/dao/model"
	"github.com/microcosm-cc/bluemonday"
)

// SaveRecordToDB 保存浏览记录到数据库
func SaveRecordToDB(userId int, recordAt int64, news *model.News) {
	p := bluemonday.StripTagsPolicy()
	record := &model.UserRecord{
		UserId:      userId,
		ReadAt:      recordAt,
		NewsId:      news.ID,
		NewsTitle:   news.Title,
		NewsChannel: news.Channel,
		NewsContent: p.Sanitize(news.Content),
	}
	dao.SaveRecordToDB(record)
}
